package com.czy.owner.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.czy.owner.R;
import com.czy.owner.entity.CarInfo;
import com.czy.owner.widget.RoundImageView;

import org.xutils.x;

import java.util.List;

/**
 * Created by wangyang on 2016/9/7 0007.
 */
public class OnLineOrderCarSelectAdapter extends BaseRecyclerAdapter<CarInfo,OnLineOrderCarSelectAdapter.CarSelectHolder> {
    private int isSelectPos = 0;
    private Context ctx;
    public OnLineOrderCarSelectAdapter(Context context, List<CarInfo> data, int isSelectPos) {
        super(context, data);
        this.ctx = context;
        this.isSelectPos = isSelectPos;
    }
    @Override
    public void onBindViewHolder(CarSelectHolder  holder, int position) {
        super.onBindViewHolder(holder, position);
        holder.bindData(data.get(position),position);
    }

    @Override
    public CarSelectHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new CarSelectHolder(layoutInflater.inflate(R.layout.item_car_popupwindow, parent, false));
    }
    

    public class CarSelectHolder extends BaseRecyclerAdapter.ViewHolder{
        private RoundImageView img_store_head_portrait;
        private TextView tv_car_name;

        public CarSelectHolder(View itemView) {
            super(itemView);
            img_store_head_portrait = (RoundImageView)itemView.findViewById(R.id.img_store_head_portrait);
            tv_car_name = (TextView)itemView.findViewById(R.id.tv_car_name);


        }
        public void bindData(CarInfo model, int pos){
            x.image().bind(img_store_head_portrait,model.getImageSrc());
            tv_car_name.setText(model.getChName());
            if(isSelectPos==pos){
                tv_car_name.setTextColor(ctx.getResources().getColor(R.color.appThemeColor));

            }else {
                tv_car_name.setTextColor(ctx.getResources().getColor(R.color.tab_title_select_normal));

            }

        }
    }
}
